package com.boc.langxiang.ui.dialog;

import android.app.Dialog;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.RelativeLayout;

import com.boc.langxiang.R;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by admin on 2016/6/29.
 */
public class WeiXinCustomerDialogFragment extends DialogFragment {


    @BindView(R.id.relayout_bg)
    RelativeLayout relayoutBg;
    private boolean mCancleAble;

    public interface WeiXinCommonListener {

        void OutSideTouch();

    }

    private WeiXinCommonListener mWeiXinListener;

    public WeiXinCommonListener getCustomerListener() {
        return mWeiXinListener;
    }

    public void setCustomerListener(WeiXinCommonListener customerListener) {
        this.mWeiXinListener = customerListener;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View inflate = inflater.inflate(R.layout.dialog_contact_weixin, container, false);
        Dialog dialog = getDialog();
        if (dialog == null) {
            return null;
        }
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
        ButterKnife.bind(this, inflate);
        return inflate;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {

        if (mWeiXinListener != null) {
            relayoutBg.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mWeiXinListener.OutSideTouch();
                }
            });
        }
    }

    @NonNull
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        Dialog dialog = super.onCreateDialog(savedInstanceState);
        dialog.getWindow().getAttributes().windowAnimations = R.style.me_pop_anim_center_style;
        return dialog;

    }


    /**
     * false表示
     *
     * @param cancleAble false表示back键没有反应
     */
    public void setBackCancelAble(boolean cancleAble) {
        setCancelable(cancleAble);
    }


}
